import request from "@/utils/request";

enum API{
    GET_ROLELIST_BYBANE = "/admin/acl/role",
    GET_ROLE_BYID = "/admin/acl/role/get/",
    ADD_ROLE = "/admin/acl/role/save",
    UPDATE_ROLE = "/admin/acl/role/update",
    REMOVE_ROLE_BYID = "/admin/acl/role/remove/",
    REMOVE_ROLE_BYIDLIST = "/admin/acl/role/batchRemove",
    GET_MENU_BY_ROLEID = "/admin/acl/permission/toAssign/",
    SET_ROLEMENU_BYROLEID = "/admin/acl/permission/doAssignAcl"
}

export const getRoleListByName = (page:number,limit:number,name:string) => request.get(API.GET_ROLELIST_BYBANE+'/'+page+'/'+limit,{params:{roleName:name}});
export const getRoleById = (id:number) => request.get(API.GET_ROLE_BYID+id);
export const addRole = (role:unknown) => request.post(API.ADD_ROLE,role);
export const updateRole = (role:unknown) => request.put(API.UPDATE_ROLE,role);
export const removeRoleById = (id:number) => request.delete(API.REMOVE_ROLE_BYID+id);
export const removeRoleByIdList = (idList:number[]) => request.delete(API.REMOVE_ROLE_BYIDLIST,{data:idList});
export const getMenuByRoleId = (id:number) => request.get(API.GET_MENU_BY_ROLEID+id);
export const setRoleMenuByRoleId = (permissionVo:unknown) => request.post(API.SET_ROLEMENU_BYROLEID,permissionVo);

export default {
    getRoleListByName,
    getRoleById,
    addRole,
    updateRole,
    removeRoleById,
    removeRoleByIdList,
    getMenuByRoleId,
    setRoleMenuByRoleId
};

